package com.plt.w2w;

import java.util.ArrayList;
import java.util.Map;

public class MainFuncBackEnd {
	Map<String,String[]> symbolTable;
	ArrayList<String> mainFuncString;
	String date;
	final int TYPE =0;
	final int VALUE =1;
	final int CREATEEVENT = 0;
	final int GENERATEOUTFIT = 1;
	final int TEMPERATURE = 1;
	
	public MainFuncBackEnd(Map<String,String[]> symbolTable,ArrayList<String> mainFuncString){
		this.symbolTable = symbolTable;
		this.mainFuncString = mainFuncString;
	}
	
	public void backEnd(){
		String createEventFunction = mainFuncString.get(0);
		int index1 = createEventFunction.indexOf("(");
		int index2 = createEventFunction.indexOf(")");
		String arguments = createEventFunction.substring(index1+1,index2);
		String[] argumentArray = arguments.split(",");
		String[] mapValues = symbolTable.get(argumentArray[0]);
		date = mapValues[VALUE];
		generateOutfit();
		
		
	}
	
	
	public void generateOutfit(){
		//interact with API to get weather details
		chooseOutfit(28,false);
		
	}
	
	public void chooseOutfit(int temperature, boolean rain){
		System.out.println("Temperature: "+temperature);
		if(temperature>=-20 && temperature<=-5){
			System.out.println("You need to wear layers: a snow jacket, a jacket and thermals.\n" +
					"Wear a woolen cap, mufflers and thick gloves.");
			if(rain)
				System.out.println("Carry umbrella. Wear snow/water proof shoes with thick socks.");
			else
				System.out.println("Wear snow/water proof shoes with thick socks.");
		}
		else if(temperature>=0 && temperature<=10){
			System.out.println("You need to wear layers: a winter jacket and thermals.\n" +
					"Wear a woolen cap, mufflers and thick gloves.");
			if(rain)
				System.out.println("Carry umbrella. Wear water-proof shoes with thick socks.");
			else
				System.out.println("Wear winter boots and socks.");
		}
		else if(temperature>=10 && temperature<=15){
			System.out.println("Wear a thick jacket/pullover.\n" +
					"Optional: woolen cap and gloves.");
			if(rain)
				System.out.println("Carry umbrella. Wear water-proof shoes.");
		}
		else if(temperature>=15 && temperature<=25){
			System.out.println("Pleasant weather. Carry a light jacket.");
			if(rain)
				System.out.println("Wear water-proof shoes.");
		}
		else if(temperature>=25 && temperature<=40){
			System.out.println("Warm weather. Wear light clothes. Wear sun-block/cap.");
			if(rain)
				System.out.println("Going to rain. Carry umbrella. Wear flip-flops.");
		}
		else if(temperature>=40 && temperature<=60){
			System.out.println("Very high temperatures. Wear light clothes. Wear sun-block/cap.");
			if(rain)
				System.out.println("Going to rain. Carry umbrella. Wear flip-flops.");
		}
			
		
	}
	
	public static void main(String args[]){
		
	}
}
